package com.wanxi.controller;

import com.wanxi.VO.UserVO;
import com.wanxi.dto.ResultDTO;
import com.wanxi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * 用户信息
 * @Author : 林子淳
 * @create 2023/3/9 16:15
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/back/user/add")
    @CrossOrigin
    protected ResultDTO add(UserVO userVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = userService.add(userVO);
        return resultDTO;
    }
    @PostMapping("/back/user/delete")
    @CrossOrigin
    protected ResultDTO delete(UserVO userVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = userService.delete(userVO);
        return resultDTO;
    }
    @GetMapping("/back/user/findAll")
    @CrossOrigin
    protected ResultDTO findAll(UserVO userVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = userService.findAll(userVO);
        return resultDTO;
    }
    @GetMapping("/back/user/findById")
    @CrossOrigin
    protected ResultDTO findById(UserVO userVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = userService.findById(userVO);
        return resultDTO;
    }
    @PostMapping("/back/user/update")
    @CrossOrigin
    protected ResultDTO update(UserVO userVO, HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ResultDTO resultDTO = userService.update(userVO);
        return resultDTO;
    }
}
